<template>
  <div class="home">
    <p>
      <i class="el-icon-s-promotion"></i>
      我的订单
    </p>
    <el-card class="page-wrap">
      <el-table :data="listData">
        <el-table-column label="编号" prop="orderNo"></el-table-column>
        <el-table-column label="商家" prop="businessName"></el-table-column>
        <el-table-column label="商品名" prop="goods"></el-table-column>
        <el-table-column label="数量" prop="number"></el-table-column>
        <el-table-column label="价格" prop="price"></el-table-column>
        <el-table-column label="时间" prop="orderDate"></el-table-column>
        <el-table-column   label="状态">
          <template slot-scope="scope">
            <el-tag type="success" effect="dark" v-if="scope.row.status===0">已支付</el-tag>
            <el-tag type="success" effect="dark" v-if="scope.row.status===1">交易成功</el-tag>
            <el-tag type="success" effect="dark" v-if="scope.row.status===2">交易失败</el-tag>
            <el-tag type="success" effect="dark" v-if="scope.row.status===3">退款进行中</el-tag>
            <el-tag type="success" effect="dark" v-if="scope.row.status===4">退款成功</el-tag>
            <el-tag type="success" effect="dark" v-if="scope.row.status===5">退款失败</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作"  min-width="100">
          <template slot-scope="scope">
            <el-button size="mini" type="danger" @click="set( scope.row)">退款</el-button>
          </template>
        </el-table-column>

      </el-table>
      <el-row type="flex" justify="center" style="margin-top: 30px">
        <el-pagination
          background
          :total="total"
          layout="prev, pager, next"
          :page-size="size"
          @current-change="currentChange">
        </el-pagination>
      </el-row>
    </el-card>
  </div>
</template>

<script>
import Request from "../api/request";

export default {
  data() {
    return {
      list: [],
      aa: 'data:image/png;base64,',
      listData: [],
      currentPage: 1,
      size: 5,

      total: 0,
    };
  },
  mounted() {
    this.getList()
  },

  methods: {
    set(row){
      if (row.status===0||row.status===1||row.status===2){
      Request.put("order",row)
      this.getList()}
    },

    getList() {
      Request.get(
        "/order/u?current=" + this.currentPage +
        "&size=" + this.size)
        .then(res => {
          this.loading = false

          this.listData = res.data.data.records
          // 分页赋值
          this.currentPage = res.data.data.current
          this.size = res.data.data.size
          this.total = res.data.data.total

        })
    },
    currentChange(page) {
      this.currentPage = page
      this.getList();
    },
    show(row) {

      Request.post("car?id=" + row.goodsId + "&type=1").then(res => {


        if (res.data.data) {
          // this.select();
          this.$message({
            duration:1000,
            type: 'success',
            message: '保存成功！'
          })
        } else {
          this.$message({
            type: 'info',
            message: ''
          })
        }


      })

    },

  },
};
</script>
<style lang="less" scoped>
h2 {
  font-weight: normal;
  font-size: 28px;
  text-align: center;
}

.home {
  width: 60%;
  margin: 20px auto;

  p {
    color: #fba320;

    i {
      font-size: 24px;
    }
  }

  .page-wrap {
    width: 100%;
    height: 100%;
    margin-top: 20px;

    .el-card__body {
      width: 100%;
      height: 100%;

      .main {
        width: 100%;
        height: 100%;
        background-color: pink;
      }
    }
  }
}

::v-deep .el-card__body {
  padding: 10px;
}
.home {
  width: 60%;
  margin: 20px auto;




  .page-wrap {
    width: 100%;
    height: 100%;
    margin-top: 20px;

    p {
      color: #000;
    }

    .content {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding-right: 20px;
      border-bottom: 1px solid rgb(214, 212, 212);

      .picture {
        width: 300px;

        img {
          width: 100%;
        }
      }

      .info {
        flex: 1;
        margin-left: 40px;

        h3 {
          margin-bottom: 20px;
          cursor: pointer;
        }
      }
    }
  }
}

::v-deep .el-card__body {
  padding: 10px;
}

.home {
  width: 60%;
  height: 800px;
  margin: 20px auto;
}

.page-wrap {
  margin-top: 30px;
  /* height: 600px; */
}

.picture {
  width: 180px;
  height: 180px;
}
</style>
